package com.wst.wst_server.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wst.wst_server.entity.Org;
import com.wst.wst_server.entity.Orgplus;
import com.wst.wst_server.service.IOrgService;
import com.wst.wst_server.service.IOrgplusService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author zyk
 * @since 2023-03-24
 */
@RestController
@RequestMapping("/orgplus")
public class OrgplusController {
    @Autowired
    IOrgplusService service;

    @RequestMapping("/getallorgplus")
    public ResponseResult<List<Orgplus>> getbyallorgplus(){
        return new ResponseResult<List<Orgplus>>(200,"ok",service.list(new QueryWrapper<Orgplus>().orderByDesc("id")));
    }

    @RequestMapping("/getbypage")
    public ResponseResult<IPage<Orgplus>> getbypage(Integer page,Integer count){
        IPage<Orgplus> p = new Page<>(page,count);
        return new ResponseResult<IPage<Orgplus>>(200,"ok",
                service.page(p,new QueryWrapper<Orgplus>().orderByDesc("id")));
    }

    @RequestMapping("/getbyorgid")
    public ResponseResult<List<Orgplus>> getbyorgid(@RequestParam Map<String,Object> map){
        System.out.println(map);
        return new ResponseResult<List<Orgplus>>(200,"ok",service.getbyorgid(map));
    }

}
